package com.example.shop.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.shop.R;
import com.example.shop.base.SCBaseActivity;
import com.example.shop.entity.LimitbuyEntity;
import com.example.sjlibrary.master.ActivityMaster;
import com.nostra13.universalimageloader.core.ImageLoader;

import butterknife.Bind;
import butterknife.ButterKnife;

public class ProductDetailActivity extends SCBaseActivity implements View.OnClickListener{

    @Bind(R.id.imgv_activity_productdetail)
    ImageView mImgvActivityProductdetail;
    @Bind(R.id.tv_title_activity_productdetail)
    TextView mTvTitleActivityProductdetail;
    @Bind(R.id.tv_market_price_activity_productdetail)
    TextView mTvMarketPriceActivityProductdetail;
    @Bind(R.id.tv_limit_price_activity_productdetail)
    TextView mTvLimitPriceActivityProductdetail;
    @Bind(R.id.edt_num_activity_productdetail)
    EditText mEdtNumActivityProductdetail;
    @Bind(R.id.bt_gwc_activity_productdetail)
    Button mBtGwcActivityProductdetail;
    AlertDialog alertDialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_detail);
        ButterKnife.bind(this);
        this.setTitleCenter("商品详情");
        this.setTvTitleBarLeft("返回", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                killSelf();
            }
        });
        Intent intent = this.getIntent();
        LimitbuyEntity.ProductlistEntity productlistEntity = intent.getParcelableExtra("product");
        ImageLoader.getInstance().displayImage(productlistEntity.getPic(), mImgvActivityProductdetail);
        mTvTitleActivityProductdetail.setText(productlistEntity.getName());
        mTvMarketPriceActivityProductdetail.setText("￥ "+productlistEntity.getMarketprice());
        mTvLimitPriceActivityProductdetail.setText("￥ "+productlistEntity.getLimitprice());
        mBtGwcActivityProductdetail.setOnClickListener(this);
        AlertDialog.Builder builder=new AlertDialog.Builder(this)
                .setTitle("温馨提示！")
                .setMessage("您的商品已加入315！")
                .setPositiveButton("继续购物！", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        killSelf();

                    }
                })
                .setNegativeButton("去购物车！", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        ActivityMaster.killOne(LimitBuyActivity.class);
                        ActivityMaster.killOne(ProductDetailActivity.class);

                    }
                });

         alertDialog = builder.create();
    }

    @Override
    public void onClick(View v) {

        alertDialog.show();
    }
}
